# Maintainer: M0Rf30 <morf3089@gmail.com>
# Co-Maintainer: Ultra-azu <ultra.public@proton.me>
# Co-Maintainer: Barnabas Czeman <trabarni@gmail.com>
# Kernel config based on: defconfig, msm8953.config, and device configs

_flavor="postmarketos-qcom-msm8953"
pkgname=linux-$_flavor
pkgver=6.12.0
pkgrel=1
pkgdesc="Close to mainline linux kernel for Qualcomm Snapdragon MSM8953"
arch="aarch64"
_carch="arm64"
url="https://github.com/msm8953-mainline/linux"
license="GPL-2.0-only"
options="!strip !check !tracedeps
	pmb:cross-native
	pmb:kconfigcheck-community
"
makedepends="
	bash
	bison
	findutils
	flex
	openssl-dev
	perl
	postmarketos-installkernel
	python3
"

_tag="$pkgver-r0"

source="
	$pkgname-v$_tag.tar.gz::$url/archive/v$_tag.tar.gz
	config-$_flavor.aarch64
"
builddir="$srcdir/linux-$_tag"

prepare() {
	default_prepare
	cp "$srcdir/config-$_flavor.$arch" .config
}

build() {
	unset LDFLAGS
	make ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-$_flavor"
}

package() {
	mkdir -p "$pkgdir"/boot

	make zinstall modules_install dtbs_install \
		ARCH="$_carch" \
		INSTALL_PATH="$pkgdir"/boot \
		INSTALL_MOD_PATH="$pkgdir" \
		INSTALL_MOD_STRIP=1 \
		INSTALL_DTBS_PATH="$pkgdir/boot/dtbs"
	rm -f "$pkgdir"/lib/modules/*/build "$pkgdir"/lib/modules/*/source

	install -Dm644 "$builddir/include/config/kernel.release" \
		"$pkgdir/usr/share/kernel/$_flavor/kernel.release"
}
sha512sums="
542189a25e3cd1bb3f994e0cf5d35db133f9fd4ede5edcd2f350d9d551c2dd9e21b1ee16c6839bcd1cf377c12bae39c06e8e47cf54e61f8603f93a9479d47a15  linux-postmarketos-qcom-msm8953-v6.12.0-r0.tar.gz
bd7235497b820c76207cb4878dd46e6180783c48b82767c0c181852e776ab8f09e429e1cc24814a7009ccb376dbd3c4471551cc5b5c1e46170dd5c4aee4f8918  config-postmarketos-qcom-msm8953.aarch64
"
